APP_DIR = ../../app

include $(APP_DIR)/Rules.make
include $(APP_DIR)/odin_inc

NAME = $(notdir $(CURDIR))
EXE_NAME = $(NAME).out

#所依赖的本地库文件，位于component目录下，
LOCAL_INC_DIR =  $(APP_DIR)/components/include
LOCAL_LIB_DIR =  $(APP_DIR)/components/lib
LOCAL_LIBS =  
LOCAL_STATIC_LIBS = $(foreach n,$(LOCAL_LIBS),$(LOCAL_LIB_DIR)/lib$(n).a)

EXE_DIR = $(APP_DIR)/_install/app_driver/

CFLAGS =  -I. -I../include -I$(LOCAL_INC_DIR)  -Wall -g  -o2 -Werror

#添加ODIN的头文件路径
CFLAGS +=  $(ODIN_INC_C_FLAG)
CFLAGS += -I$(OPEN_LIB_DIR)/$(JSON_C_VERSION)/$(COMPILER)/include/json-c
CFLAGS += -I$(OPEN_LIB_DIR)/zlib/$(COMPILER)/include/
CFLAGS += -I$(OPEN_LIB_DIR)/srt/$(COMPILER)/include/srt

CFLAGS += $(ADD_SUBLIB_INC)


LDFLAGS = -Xlinker "-(" -L$(LOCAL_LIB_DIR) $(LOCAL_STATIC_LIBS) -Xlinker "-)"
LDFLAGS += $(ODIN_STATIC_LIBS) $(ODIN_DIR)/open_lib/$(JSON_C_VERSION)/$(COMPILER)/lib/libjson-c.a
LDFLAGS += $(OPEN_LIB_DIR)/zlib/$(COMPILER)/lib/libzlib.a
LDFLAGS += $(OPEN_LIB_DIR)/srt/$(COMPILER)/lib/libsrt.a

LDFLAGS +=  -L $(COMPILE_HEAD_PATH)/usr/lib -lpthread -lrt -lm -ldl -rdynamic -lssl -lcrypto
LDFLAGS +=  -lstdc++

objects := $(patsubst %.c,%.o,$(wildcard *.c))

all: core
	$(CP) $(EXE_NAME) $(EXE_DIR)
	
core : $(objects)
	rm -f ./$(EXE_NAME)
	$(COMPILE_PREFIX)gcc  $(objects) -o $(EXE_NAME) $(LDFLAGS) 
	#$(COMPILE_PREFIX)objdump -p $@ | grep NEEDED > NEED.dep
	
$(objects): %.o: %.c
	$(COMPILE_PREFIX)gcc -c $(CFLAGS) $< -o $@
	

install:
	cp $(EXE_NAME) $(EXE_DIR)
	@echo $(EXE_DIR)

clean:
	rm -f ./$(EXE_NAME)
	rm -f *.o

distclean: clean
	rm -f *.o
	
